//一个长度为n-1的递增排序数组中的所有数字都是唯一的
//并且每个数字都在范围0~n-1之间
//在范围0~n-1内的n个数字中有且仅有一个数字不在该数组中,请找出这个数字

import java.util.Scanner;

public class test8 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        int result = findMin(nums);
        System.out.println(result);
    }
    public static int findMin(int[] nums) {
        if(nums.length==0){
            return -1;
        }
        int left = 0,right=nums.length-1;
        while (left<right){
            int mid = left+(right-left)/2;
            if(nums[mid]!=mid){
                right=mid;
            }else{
                left=mid+1;
            }
        }
        if(nums[left]==left){
            return left+1;
        }
        return left;
    }
}
